package test;

import java.util.ArrayList;

import functions.Function;
import functions.FunctionIF;
import functions.PolynTerm;

public class Functions_test {

	/**
	 * @param args
	 */
	public static void main(String[] args)
	{
		Function f = new Function();

		// =========
		ArrayList<FunctionIF> product1 = new ArrayList<FunctionIF>();

		// ---
		Function t1 = new Function();
		ArrayList<FunctionIF> tt = new ArrayList<FunctionIF>();
		tt.add(new PolynTerm(1, 1));
		
		t1.addProductTerm(tt);
		
		ArrayList<FunctionIF> tt1 = new ArrayList<FunctionIF>();
		tt1.add(new PolynTerm(1, 0));

		t1.addProductTerm(tt1);
		// ---

		f.addProductTerm(product1);
		// ========

		// =========
		ArrayList<FunctionIF> product2 = new ArrayList<FunctionIF>();

		// ---
		Function t2 = new Function();
		ArrayList<FunctionIF> tt2 = new ArrayList<FunctionIF>();
		tt2.add(new PolynTerm(1, 1));
		
		t2.addProductTerm(tt2);
		
		ArrayList<FunctionIF> tt3 = new ArrayList<FunctionIF>();
		tt3.add(new PolynTerm(1, 0));

		t2.addProductTerm(tt3);
		// ---


		f.addProductTerm(product2);
		// ========

		double x = 4;
		FunctionIF df = f.diff();

		System.out.println(f);
		System.out.println(f.eval(x));
		double actual = Math.pow(x, 4) - x - 24;
		System.out.println("Actual : " + actual);
		System.out.println("---------------------Diff\n-----");
		System.out.println(df);
		System.out.println(df.eval(x));
	}

}
